local sk__yinyang = fk.CreateSkill {

  name = "sk__yinyang",

  tags = { Skill.Compulsory, },

}



sk__yinyang:addEffect(fk.HpChanged, {
  name = "sk__yinyang",
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(sk__yinyang.name) then
      return (player.hp > player:getLostHp() and not player:hasSkill("sk__jiyang", true)) or
          (player.hp < player:getLostHp() and not player:hasSkill("sk__jiyin", true)) or
          (player.hp == player:getLostHp() and not player:hasSkill("sk__xiangsheng", true))
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player.hp > player:getLostHp() then
      room:handleAddLoseSkills(player, "sk__jiyang|-sk__jiyin|-sk__xiangsheng", nil, true, false)
    elseif player.hp < player:getLostHp() then
      room:handleAddLoseSkills(player, "sk__jiyin|-sk__jiyang|-sk__xiangsheng", nil, true, false)
    elseif player.hp == player:getLostHp() then
      room:handleAddLoseSkills(player, "sk__xiangsheng|-sk__jiyang|-sk__jiyin", nil, true, false)
    end
  end,
})
sk__yinyang:addEffect(fk.MaxHpChanged, {
  name = "sk__yinyang",
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(sk__yinyang.name) then
      return (player.hp > player:getLostHp() and not player:hasSkill("sk__jiyang", true)) or
          (player.hp < player:getLostHp() and not player:hasSkill("sk__jiyin", true)) or
          (player.hp == player:getLostHp() and not player:hasSkill("sk__xiangsheng", true))
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player.hp > player:getLostHp() then
      room:handleAddLoseSkills(player, "sk__jiyang|-sk__jiyin|-sk__xiangsheng", nil, true, false)
    elseif player.hp < player:getLostHp() then
      room:handleAddLoseSkills(player, "sk__jiyin|-sk__jiyang|-sk__xiangsheng", nil, true, false)
    elseif player.hp == player:getLostHp() then
      room:handleAddLoseSkills(player, "sk__xiangsheng|-sk__jiyang|-sk__jiyin", nil, true, false)
    end
  end,
})

sk__yinyang:addAcquireEffect(function(self, player, is_start)
  local room = player.room
  if player.hp > player:getLostHp() then
    room:handleAddLoseSkills(player, "sk__jiyang|-sk__jiyin|-sk__xiangsheng", nil, true, false)
  elseif player.hp < player:getLostHp() then
    room:handleAddLoseSkills(player, "sk__jiyin|-sk__jiyang|-sk__xiangsheng", nil, true, false)
  elseif player.hp == player:getLostHp() then
    room:handleAddLoseSkills(player, "sk__xiangsheng|-sk__jiyang|-sk__jiyin", nil, true, false)
  end
end)


sk__yinyang:addLoseEffect(function(self, player, is_start)
  local room = player.room
  room:handleAddLoseSkills(player, "-sk__jiyang|-sk__jiyin|-sk__xiangsheng", nil, true, false)
end)


return sk__yinyang
